//
//  UILable + Extension.swift
//  weibo1
//
//  Created by changhongliang on 2017/7/21.
//  Copyright © 2017年 richinfo. All rights reserved.
//

import UIKit
extension UILabel {
    convenience init(title: String,
                     fontSize: CGFloat = 14,
                     color: UIColor = UIColor.darkGray,
                     screenInset: CGFloat = 0) {
        
        self.init()
        
        text = title
        textColor = color
        font = UIFont.systemFont(ofSize: fontSize)
        
        numberOfLines = 0
        
        if screenInset == 0 {
            textAlignment = .center
        } else {
            // 设置换行宽度
            preferredMaxLayoutWidth = UIScreen.main.bounds.width - 2 * screenInset
            textAlignment = .left
        }
    }
}
